import tornado
from tornado.websocket import WebSocketHandler
from tornado.web import RequestHandler
import time

from service.handler.test import slave_data


class Token(tornado.web.RequestHandler):
    def post(self):
        print('Token')
        return slave_data.get_token


class SlaveSec(tornado.websocket.WebSocketHandler):

    def check_origin(self, str):
        return True

    def open(self):
        print('websocket open!')
        self.write_message(slave_data.task_data)
        # time.sleep(5)
        # self.write_message(slave_data.task_data)

    def on_message(self, message: str or bytes):
        print('websocket on_message!')

    def on_close(self):
        print('websocket on_close!')



